#include "StaticObjects.h"


CStaticObjects::CStaticObjects(void)
{

}

CStaticObjects::CStaticObjects(int kind, int id, D3DXVECTOR3 pos)
{
	iKind = kind;
	iType = id;
	Pos = pos;
	SetRectDraw(kind, id);
}

CStaticObjects::~CStaticObjects(void)
{
}

void CStaticObjects::SetTexture(char* filename)
{
	this->texture = new CTexture(filename);
}

void CStaticObjects::Render(CObjects *obj)
{
	RECT screen = G_ScreenRect;
	SetRectDraw(obj->iKind, obj->iType);
	this->texture->DrawRect(obj->Pos.x - screen.left, obj->Pos.y - screen.top, rectDraw);
}

void CStaticObjects::CreateRectDraw(int left, int top, int width, int height)
{
	rectDraw.left = left;
	rectDraw.top = top;
	rectDraw.right = left + width;
	rectDraw.bottom = top + height;
}

void CStaticObjects::SetRectDraw(int Kind, int ID)
{
	switch (Kind)
	{
	case 0:	//block
		SetTexture(BLOCKS_FILE);
		rectDraw.left = (ID%8)*50;
		rectDraw.right = rectDraw.left + 50;
		rectDraw.top = (ID/8)*50;
		rectDraw.bottom = rectDraw.top + 50;
		break;
	case 1:	
		break;
	case 2: //Scenery
		SetTexture(SCENE_FILE);
		switch (ID)
		{
		case 0:
			CreateRectDraw(0, 0, 300, 150);
			break;
		case 1:
			CreateRectDraw(300, 0, 150, 200);
			break;
		case 2:
			CreateRectDraw(0, 150, 300, 100);
			break;
		case 3:
			CreateRectDraw(0, 250, 200, 250);
			break;
		case 4:
			CreateRectDraw(200, 300, 100, 100);
			break;
		case 5:
			CreateRectDraw(200, 400, 100, 100);
			break;
		case 6:
			CreateRectDraw(300, 200, 100, 300);
			break;
		case 7:
			CreateRectDraw(400, 200, 150, 100);
			break;
		case 8:
			CreateRectDraw(400, 350, 150, 50);
			break;
		case 9:
			CreateRectDraw(400, 400, 150, 100);
			break;
		default:
			break;
		}
		break;
	default:
		break;
	}
}